//package org.example.protocol.modules;
//
//import cn.hutool.log.LogFactory;
//import org.artifact.core.server.ServerContext;
//import org.artifact.core.context.session.Session;
//import org.artifact.core.context.packet.NetworkPacket;
//import org.artifact.core.context.packet.NetworkHeader;
//import org.artifact.core.context.bytebuf.IByteBuff;
//import cn.hutool.core.map.MapProxy;
//import java.util.function.Consumer;
//import java.util.function.BiConsumer;
//import java.util.Collection;
//import java.util.Map;
//import java.util.List;
//import org.artifact.core.constant.ArtifactErrorCode;
//import org.artifact.core.util.LogicUtil;
//import org.artifact.core.lang.IModule;
//import co.paralleluniverse.fibers.SuspendExecution;
//import org.example.protocol.structs.*;
//
//@SuppressWarnings("unchecked")
//public interface PlayerModule extends IModule{
//	public static final int MODULE_ID = 6881;
//
//
//	default int getModuleId(){
//		return 6881;
//	}
//
//	/** 分发  */
//	default Consumer<NetworkPacket> disp(Session session,NetworkPacket packet) throws SuspendExecution, InterruptedException{
//		int method = packet.getHeader(NetworkHeader.METHOD);
//		switch (method) {
//			case 6890:{
//				return enterGameDecoder(session,packet);
//			}
//			default:
//				throw LogicUtil.error(ArtifactErrorCode.NOT_FOND_ACTION);
//		}
//	}
//
//
//	/** 进入游戏 */
//	default Consumer<NetworkPacket> enterGameDecoder(Session session,NetworkPacket packet) throws SuspendExecution, InterruptedException{
//		MapProxy proxy = MapProxy.create(packet.getBody());
//		java.lang.String loginServerId = proxy.getStr(451300935);
//		java.lang.String token = proxy.getStr(110541305);
//		LogFactory.get().debug("Req enterGame -> loginServerId:{} token:{} ", loginServerId, token);
//		return enterGame(session, packet, loginServerId, token);
//	}
//
//	/** 进入游戏 */
//	Consumer<NetworkPacket> enterGame(Session session,NetworkPacket packet, java.lang.String loginServerId, java.lang.String token) throws SuspendExecution, InterruptedException;
//
//	default Consumer<NetworkPacket> _enterGame(Session session, PlayerDTO player, int index){
//		return (NetworkPacket packet) -> {
//		        packet.setHeader(NetworkHeader.STATUS,0);
//		        packet.getBody().clear();
//				packet.getBody().put(-985752863,player);
//				packet.getBody().put(100346066,index);
//				LogFactory.get().debug("Resp enterGame -> player:{} index:{} ", player, index);
//				session.send(packet);
//			};
//	}
//
//	default Consumer<NetworkPacket> _enterGame_error(Session session,Throwable throwable,Consumer<Throwable> consumer){
//        return (NetworkPacket packet) -> {
//            int errorCode = LogicUtil.getErrorCode(throwable,consumer);
//            packet.setHeader(NetworkHeader.STATUS, errorCode);
//            packet.getBody().clear();
//            LogFactory.get().debug("Resp enterGame -> Error : {}",errorCode);
//            session.send(packet);
//        };
//	}
//
//
//	/** 推送 */
//	default void notifyPlayer(Session session, java.lang.String loginServerId, java.lang.String token,BiConsumer<Session,NetworkPacket> consumer){
//		NetworkPacket packet = new NetworkPacket();
//		packet.setHeader(NetworkHeader.COMMAND, 450970506);
//        packet.setHeader(NetworkHeader.MODULE, 6881);
//        packet.setHeader(NetworkHeader.METHOD, 17290);
//		packet.getBody().put(451300935,loginServerId);
//		packet.getBody().put(110541305,token);
//		LogFactory.get().debug("Push notifyPlayer -> loginServerId:{} token:{} ", loginServerId, token);
//		if(session != null){
//		    consumer.accept(session,packet);
//		}
//	}
//
//	default void notifyPlayer(Collection<Session> sessions, java.lang.String loginServerId, java.lang.String token,BiConsumer<Session,byte[]> consumer){
//		NetworkPacket packet = new NetworkPacket();
//		packet.setHeader(NetworkHeader.COMMAND, 450970506);
//		packet.setHeader(NetworkHeader.MODULE, 6881);
//        packet.setHeader(NetworkHeader.METHOD, 17290);
//		packet.getBody().put(451300935,loginServerId);
//		packet.getBody().put(110541305,token);
//        LogFactory.get().debug("Push notifyPlayer -> loginServerId:{} token:{} ", loginServerId, token);
//		// IByteBuff byteBuff = ServerContext.me().getByteBuffFactory().allocate();
//		IByteBuff byteBuff = ServerContext.me().getProtocolBufferProvider().create(null);
//		packet.toByteBuff(byteBuff);
//		byte[] data = byteBuff.array();
//		for (Session session : sessions) {
//		    if(session != null){
//			    consumer.accept(session,data);
//			}
//		}
//	}
//
//}